from launch import LaunchDescription
from launch_ros.actions import Node
from ament_index_python.packages import get_package_share_directory
import os

def generate_launch_description():
    # 获取配置文件路径
    params_file = os.path.join(
        get_package_share_directory('slam_config'),
        'config',
        'mapper_params_online_async.yaml'
    )

    return LaunchDescription([
        Node(
            package='slam_toolbox',
            executable='async_slam_toolbox_node',
            name='slam_toolbox',
            output='screen',
            parameters=[params_file],
            remappings=[
                ('scan', '/scan')  # 映射激光数据话题（与雷达驱动发布的话题一致）
            ]
        )
    ])
